package Test;

import static org.junit.Assert.*;

import org.junit.*;

import Spil.*;

public class TestTerritory {

	private Ownable territoryCold;
	private Ownable territoryCastle;
	private Player player;
	private Player buyer;
	
	@Before
	public void setUp() throws Exception {
      	this.player = new Player("Anders And", 1);
      	this.buyer = new Player("Sorte Per", 1);
      	this.territoryCold = new Territory(700, 3000, "Cold Desert", 2);
      	this.territoryCastle = new Territory(4000, 8000, "Castle", 22);
      	this.territoryCold.setOwner(buyer);
      	this.territoryCastle.setOwner(buyer);
	}

	@After
	public void tearDown() throws Exception {
      	this.player = new Player("Anders And", 1);
      	this.buyer = new Player ("Sorte Per", 1);
	}
	
	@Test
	public void testLandOnFieldCold() {
		int expected = 30000;
		int actual = this.player.bank.getBalance();
      	assertEquals(expected, actual);
      	
      	actual = this.buyer.bank.getBalance();
      	assertEquals(expected, actual);
      	
      	this.territoryCold.landOnField(this.player);
      	
      	expected = 30000 - 700;
      	actual = this.player.bank.getBalance();
      	assertEquals(expected,actual);
      	
      	expected = 30000 + 700;
      	actual = this.buyer.bank.getBalance();
      	assertEquals(expected,actual);
	}

	@Test
	public void testLandOnFieldCastle() {
		int expected = 30000;
		int actual = this.player.bank.getBalance();
      	assertEquals(expected, actual);
      	
      	actual = this.buyer.bank.getBalance();
      	assertEquals(expected, actual);
      	
      	this.territoryCastle.landOnField(this.player);
      	
      	expected = 30000 - 4000;
      	actual = this.player.bank.getBalance();
      	assertEquals(expected,actual);
      	
      	expected = 30000 + 4000;
      	actual = this.buyer.bank.getBalance();
      	assertEquals(expected,actual);
	}
}
